// ==UserScript==
// @name           Yahoo Fantasy Baseball Add Players Links
// @namespace      http://glenncarr.com/greasemonkey/yahoofantasy
// @include        *baseball.fantasysports.yahoo.com/*
// @author         Glenn Carr (glenn at glenncarr dot com)
// @description    Add links for displaying probable starters and players stats over last month
// $LastChangedRevision: 571 $
// $LastChangedDate: 2010-07-27 04:21:26 +0000 (Tue, 27 Jul 2010) $
// ==/UserScript==
/*
   Updates:
   14-Jul-2010 - Added links
*/
(function() {

var subnav = document.getElementById( 'yspsubnav' );
if ( subnav == null )
    return;

var lis = subnav.getElementsByTagName( 'li' );
lis[ lis.length - 1 ].setAttribute( "class", "" );
var ul = lis[ 0 ].parentNode;

GM_addStyle( '#yspsubnav a, #yspsubnav strong {padding:8px 5px 10px;}' );

// Probable pitchers
var li = document.createElement( 'li' );
var url = location.href.replace( /(^.*\/b\d\/\d+).*$/i, '$1/players?status=A&pos=S_P&stat1=S_L30&sort=AR' );
li.innerHTML = '<a href="' + url + '">Starters</a>';
ul.appendChild( li );

// Batters ranked over the last month
var li = document.createElement( 'li' );
var url = location.href.replace( /(^.*\/b\d\/\d+).*$/i, '$1/players?status=A&pos=B&cut_type=33&stat1=S_L30&sort=AR' );
li.innerHTML = '<a href="' + url + '">Batters</a>';
ul.appendChild( li );

// Pitchers ranked over the last month
var li = document.createElement( 'li' );
var url = location.href.replace( /(^.*\/b\d\/\d+).*$/i, '$1/players?sort=AR&sdir=1&status=A&pos=P&stat1=S_L30' );
li.innerHTML = '<a href="' + url + '">Pitchers</a>';
ul.appendChild( li );

// Today's batters
var li = document.createElement( 'li' );
var url = location.href.replace( /(^.*\/b\d\/\d+).*$/i, '$1/players?sort=60&sdir=1&status=ALL&pos=B&stat1=S_L' );
li.innerHTML = '<a href="' + url + '">Today</a>';
ul.appendChild( li );
})();